package Task23;

import Task22.Main;

import java.util.Scanner;

/**
 * 计算字符串的编辑距离
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String str1 = scanner.next();
            String str2 = scanner.next();
            int step = getNum(str1,str2);
            System.out.println(step);
        }
    }
    public static int getNum(String str1,String str2){
        char[] chars1 = str1.toCharArray();
        char[] chars2 = str2.toCharArray();
        int len1 = str1.length();
        int len2= str2.length();
        int[][] dp = new int[len1 + 1][len2 + 1];
        //删除字符串操作
        //当字符串str2为空时,需要删除的次数
        for (int i = 0; i <= len1; i++) {
            dp[i][0] = i;
        }
        //添加字符串操作
        //当字符串str1为空时,需要添加的次数
        for (int j = 0; j <= len2; j++) {
            dp[0][j] = j;
        }
        for (int i = 1; i <= chars1.length; i++) {
            for (int j = 1; j <= chars2.length; j++) {
                dp[i][j] = Math.min(dp[i - 1][j],dp[i][j - 1]) + 1;
                if(chars1[i - 1] == chars2[j - 1]){
                    dp[i][j] = Math.min(dp[i - 1][j - 1],dp[i][j]);
                }else {
                    dp[i][j] = Math.min(dp[i - 1][j - 1] + 1,dp[i][j]);
                }
            }
        }
        return dp[len1][len2];
    }
}
